import api from '../../../fetch/api'

export default {
    data() {
        return {
            bigImgPath: ''
        }
    },
    created() {
        this.getItemList();
    },
    methods: {
        getList() {
            this.getItemList(this.searchParams);
        },
        showBigImgModal(name, path) {
            this.bigImgPath = path;
            this.toOpenImgModal(name, path);
        },
        //获取列表
        getItemList(aparams) {
            let self = this,
                params = {
                    page: this.pageNumber,
                    rp: this.pageSize
                };
            params = $.extend({}, params, aparams);
            // API.coupon.GetTraderListData(params)
            api.fetchGet('/compaign/waterList.do', params)
                .then(res => {
                    console.log('getListResult', res)
                    let data = res.data,
                        list = data.rows;
                    self.tbodysInfo = list;
                    self.total = data.total;
                }, err => { })
        },
        exportData() {
            let self = this;
            let theadsArr = []
            for(let i = 0; i<self.theadsInfo.length; i++){
            if(self.theadsInfo[i].checked){
                theadsArr.push(self.theadsInfo[i].prop)
            }
            }
            let params = {
                meterList: theadsArr.join(',')
            };
            params = $.extend({}, params, this.searchParams);
            self.showDialog("确认导出该报表?", '', function () {
                self.toExportAsync('compaign/exportWater.do', params)
            })
        }
    },
    filters: {
        applyObj: function (value) {
            if (value) {
                var str = value.split(",")
                var newstr = str.map(function (val) {
                    switch (Number(val)) {
                        case 0:
                            return "一点停手机用户"
                            break;
                        case 1:
                            return "一点停微信用户"
                            break;
                        case 2:
                            return "游客"
                            break;
                        case 3:
                            return "特定用户"
                            break;
                        default:
                            break;

                    }

                })
                return newstr.join("，");
            } else {
                return ''
            }
        },
        applySceneType: function (value) {

            switch (value) {
                case 0:
                    return "公开"
                    break;
                case 1:
                    return "内部"
                    break;
                default:
                    break;
            }
        },
        applyScene: function (value) {
            if (value) {
                var str = value.split(",")
                var newstr = str.map(function (val) {
                    switch (Number(val)) {
                        case 0:
                            return "扫二维码"
                            break;
                        case 1:
                            return "一点停微信"
                            break;
                        case 2:
                            return "一点停APP"
                            break;
                        default:
                            break;

                    }

                })
                return newstr.join("，");
            } else {
                return '';
            }
        },
        reliefType: function (value) {

            switch (value) {
                case "AMOUNT_DEDUCTION":
                    return "扣减优惠"
                    break;
                case "FREE":
                    return "全免优惠"
                    break;
                case "AMOUNT_DISCOUNT":
                    return "折扣优惠"
                    break;
                case "FIXED_AMOUNT":
                    return "定额优惠"
                    break;
                case "TIME":
                    return "时间优惠"
                    break;
                default:
                    break;

            }
        },
        validStatus: function (value) {

            switch (value) {
                case "VALID":
                    return "启用"
                    break;
                case "FROZE":
                    return "禁用"
                    break;
                default:
                    break;

            }
        }
    }
}